//
// Created by pangy on 2025/5/7.
//
// 斐波那契数列求值
#include <stdio.h>

int k_fibonaci(int k, int m);

int main() {
    int k, m, value;
    k = 5;
    m = 20;

    value = k_fibonaci(k, m);
    printf("%d阶斐波那契数列的第%d项值为: %d\n", k, m, value);
    return 0;
}

int k_fibonaci(int k, int m) {
    if (m < k - 1) {
        return 0;
    } else if (m == k - 1) {
        return 1;
    }
    int result = 0;
    for (int i = 1; i <= k; ++i) {
        result += k_fibonaci(k, m - i);
    }
    return result;
}